package cn.moukou.dictator.pojo.node;

import cn.moukou.dictator.pojo.*;
import cn.moukou.dictator.util.*;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import org.neo4j.ogm.annotation.GeneratedValue;
import org.neo4j.ogm.annotation.Id;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Property;
import org.neo4j.ogm.annotation.typeconversion.Convert;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Data
@NodeEntity
public class KVNode {
    //public
    @Id
    @GeneratedValue
    private Long id;

    private String path;

    @Property("node_type")
    private String nodeType;

    @Convert(StudentConverter.class)
    Student student;

    @Convert(TeacherConverter.class)
    Teacher teacher;

    @Convert(ClassRoomConverter.class)
    ClassRoom classRoom;

    @Convert(CompetitionConverter.class)
    Competition competition;

    @Convert(AwardConverter.class)
    Award award;

    @Convert(StudentOrganizationConverter.class)
    StudentOrganization studentOrganization;

    @Convert(ActivityConverter.class)
    Activity activity;

    public String getNodeName() {
        switch (nodeType) {
            case "activity":
                return activity.getName();
            case "award":
                return award.getName();
            case "class_room":
                return classRoom.getName();
            case "competition":
                return competition.getName();
            case "student":
                return student.getName();
            case "student_organization":
                return studentOrganization.getName();
            case "teacher":
                return teacher.getName();
            default:
                return null;
        }
    }
}
